/* Basic test of LED output, dual PWM motor drivers and dual photodiode input */ /* 5, 6 PWM for motors A0, A1 - phototransistors A2, A3 - LED (A2 is Anode) */ int val0 = 0; int val1 = 0; void setup() { // initialize the digital pin as an output. // Pin 13 has an LED connected on most Arduino boards: pinMode(13, OUTPUT); pinMode(A2, OUTPUT); pinMode(A3, OUTPUT); pinMode(9, OUTPUT); pinMode(10, OUTPUT); Serial.begin(57600); } void loop() { digitalWrite(13, HIGH); // set the LED on digitalWrite(A2, HIGH); // set the LED on digitalWrite(A3, LOW); // set the LED on delay(100); // wait for a 1/10 second digitalWrite(13, LOW); // set the LED off digitalWrite(A2, LOW); // set the LED on digitalWrite(A3, HIGH); // set the LED on delay(100); // wait for a 1/10 second val0 = analogRead(A0); // read the input pin val1 = analogRead(A1); // read the input pin Serial.print(val0); Serial.print("\t"); Serial.println(val1); analogWrite(10, 255-(val0-500)/2); // set PWM dutycycle from photodiode level analogWrite(9, 255-(val1-500)/2); // set PWM dutycycle from photodiode level }